home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / source / srobj.rex < prev    next >
Encoding:
OS/2 REXX Batch file  |  1995-03-25  |  1.8 KB  |  48 lines

  1. PARSE UPPER ARG savf action dtaf mbr
  2.  
  3.   /*---------------------------------------------------------------*/
  4.   /* SAVFREX - Copies data to and from a savefile.                 */
  5.   /*---------------------------------------------------------------*/
  6.   /*                                                               */
  7.   /* Arguments:                                                    */
  8.   /*   savf - Library and savefile name seperated by a '/'.        */
  9.   /*   action - 'TOSAVF' - Data file to Savefile.                  */
  10.   /*            'FROMSAVF' - Savefile to Data file.                */
  11.   /*   dtaf - Library and data file name seperated by a '/'.       */
  12.   /*   mbr - data file member name                                 */
  13.   /*                                                               */
  14.   /*---------------------------------------------------------------*/
  15.  
  16. /* fix the member name */
  17. If Length(mbr) == 0 Then mbr = '*First'
  18.  
  19. /* Evaluate the action argument */
  20. SELECT
  21.  
  22.   When action = 'TOSAVF' THEN DO
  23.     /* copy the data from data file to savefile */
  24.     'OVRDBF FILE(STDIN) TOFILE('dtaf') MBR('mbr')'
  25.     'OVRDBF FILE(STDOUT) TOFILE('savf')'
  26.   END
  27.  
  28.   When action = 'FROMSAVF' THEN DO
  29.     /* copy the data from savf to data file */
  30.     'OVRDBF FILE(STDIN) TOFILE('savf')'
  31.     'OVRDBF FILE(STDOUT) TOFILE('dtaf') MBR('mbr')'
  32.   END
  33.  
  34.   Otherwise
  35.     /* exit program if action is not found */
  36.     Exit
  37.  
  38. END                            /* End Select */
  39.  
  40. /* reads a line from stdin and writes it to stdout */
  41. DO FOREVER
  42.   PARSE LINEIN line            /* read a line from stdin */
  43.   IF line == '' THEN LEAVE     /* leave do if no data */
  44.   SAY line                     /* write to stdout */
  45. END
  46.  
  47. RETURN                         /* return to caller */
  48.